-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(tpu): add tpu queued resources time bound sample. #9617
Conversation
…u_queued_resources_delete_force and tpu_queued_resources_delete samples, created tests
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
// For more information about supported TPU types for specific zones, | ||
// see https://cloud.google.com/tpu/docs/regions-zones | ||
String zone = "europe-west4-a"; | ||
// The name for your TPU. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please match the description with the one in documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Followed documentation for naming and description.
// Software version that specifies the version of the TPU runtime to install. | ||
// For more information see https://cloud.google.com/tpu/docs/runtimes | ||
String tpuSoftwareVersion = "tpu-vm-tf-2.14.1"; | ||
// The name for your Queued Resource. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto. Please match the description with the one in documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented out code is not the best practice. It makes a difficult dev experience in docs.
Please remove all the commented imports and code.
If you want to show more than one option, I've suggested a simpler format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Fixed code
// Uncomment this method if you want to use time bound configurations | ||
// Method to convert a string timestamp to a Protobuf Timestamp object | ||
// private static Timestamp convertStringToTimestamp(String timestampString) { | ||
// Instant instant = Instant.parse(timestampString); | ||
// return Timestamp.newBuilder() | ||
// .setSeconds(instant.getEpochSecond()) | ||
// .setNanos(instant.getNano()) | ||
// .build(); | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Removed
//QueuedResource.QueueingPolicy.newBuilder() | ||
// You can specify a time before which the resource should be allocated. | ||
// corresponds --valid-after-time flag | ||
//.setValidAfterTime(convertStringToTimestamp(validAfterTime)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add this line below 106, and modify it to include the validAfterTime directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Fixed
String parent = String.format("projects/%s/locations/%s", projectId, zone); | ||
// Create a Duration object representing 6 hours. | ||
Duration validAfterDuration = Duration.newBuilder().setSeconds(6 * 3600).build(); | ||
// Duration validUntilDuration = Duration.newBuilder().setSeconds(6 * 3600).build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend removing this. It can be easily done with a single tweak to this sample.
// Timestamp validAfterTime = Timestamps.parse("2024-10-14T09:00:00Z"); | ||
// Timestamp validUntilTime = Timestamps.parse("2024-12-14T09:00:00Z"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose one of these. Not necessary to show both.
QueuedResource.QueueingPolicy.newBuilder() | ||
// Use one of the following queueing policies | ||
.setValidAfterDuration(validAfterDuration) | ||
// .setValidUntilDuration(validUntilDuration) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this.
// .setValidAfterTime(validAfterTime) | ||
// .setValidUntilTime(validUntilTime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose one of these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kindly address the comments before merging.
Description
Documentation -> https://cloud.google.com/tpu/docs/queued-resources
This example describes how to create a queuedResource with a specific time-bound configuration. Some configurations are commented out to avoid creating many similar samples.
NodeJs sample -> GoogleCloudPlatform/nodejs-docs-samples#3907
Fixes #
Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.
Checklist
pom.xml
parent set to latestshared-configuration
mvn clean verify
requiredmvn -P lint checkstyle:check
requiredmvn -P lint clean compile pmd:cpd-check spotbugs:check
advisory only